//
//  AlbumTag.swift
//  hello
//
//  Created by 赵康 on 2024/11/11.
//

import Fluent
extension AlbumTag {
	struct Migration: AsyncMigration {
		var name: String { "AlbumTagMigration" }
		func prepare(on database: any Database) async throws {
			try await database.schema(AlbumTag.schema)
				.id()
				.field(AlbumTag.FieldKeys.album, .uuid, .required, .references(Album.schema, .id))
				.field(AlbumTag.FieldKeys.tag, .uuid, .required, .references(Tag.schema, .id))
				.field(AlbumTag.FieldKeys.createdAt, .datetime, .required)
				.field(AlbumTag.FieldKeys.updatedAt, .datetime, .required)
				.field(AlbumTag.FieldKeys.isDeleted, .bool, .required, .custom("DEFAULT FALSE"))
				.create()
		}
		func revert(on database: any Database) async throws {
			try await database.schema(AlbumTag.schema).delete()
		}
	}
}
